<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #app{
        width: 100px;
        height: 100px;
        border: 1px solid orangered;
    }
</style>
<body>
    <div id="app" draggable="true">
        可拖拽
    </div>
    <script>
        let timer = null;
        const app = document.getElementById("app");
        app.addEventListener("drag",throttle(function(e){
            console.log(e.offsetY);
        }))
        function throttle(fn,delay=500){
            console.log(arguments);
                if(timer){
                return 
            }
            timer = setTimeout(()=>{
                // arguments 是函数内部的一个对象，接收函数传递过来的参数
                console.log(arguments);
                fn.apply(this.arguments);
                timer = null;
            },500)
            
        }
    </script>
</body>
</html>